//
//  UIButton+myFont.m
//  ios开发常用工具类收集
//
//  Created by zxy on 2018/4/18.
//  Copyright © 2018年 zssh. All rights reserved.
//

#import "UIButton+myFont.h"
#import <objc/runtime.h>
@implementation UIButton (myFont)


+(void)load{
    Method m1 = class_getInstanceMethod([self class], @selector(initWithCoder:));
    Method m2 = class_getInstanceMethod([self class], @selector(initWithMyCoder:));
    /*交换二个方法实现，达到拦截系统方法效果*/
    method_exchangeImplementations(m1, m2);
}


/*此方法在xib或者stroybord创建控件时走这个方法*/
-(instancetype)initWithMyCoder:(NSCoder *)aDecode{
   self = [self initWithMyCoder:aDecode];
    if(self){
        //部分不像改变字体的 把tag值设置成333跳过
        if(self.titleLabel.tag != 333){
            CGFloat fontsize = self.titleLabel.font.pointSize;
            self.titleLabel.font = [UIFont systemFontOfSize:fontsize*SizeScale];
        }
    }
    return self;
}


@end
